home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 April: Penguin on DISC / ADC Developer CD (1993-04) (''Penguin On DISC'')_iso / Dev.CD Apr 93.iso / Utilities / MPW Interfaces 7.1 Beta / CIncludes / TextEdit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-28  |  10.6 KB  |  350 lines  |  [TEXT/MPS ]

  1.  
  2. /************************************************************
  3.  
  4. Created: Saturday, July 27, 1991 at 7:16 PM
  5.  TextEdit.h
  6.  C Interface to the Macintosh Libraries
  7.  
  8.  
  9.   Copyright Apple Computer, Inc. 1985-1991
  10.   All rights reserved
  11.  
  12. *** Warning: This is an alpha version of the Interfaces for Cube-E. 
  13. ***          Things may change.  Caveat Programmer.
  14.  
  15.  
  16. */
  17.  
  18.  
  19. #ifndef __TEXTEDIT__
  20. #define __TEXTEDIT__
  21.  
  22. #ifndef __QUICKDRAW__
  23. #include <Quickdraw.h>
  24. #endif
  25.  
  26.  
  27. enum {
  28.  
  29.  
  30. /* Justification styles */
  31.  teJustLeft = 0,
  32.  teJustCenter = 1,
  33.  teJustRight = -1,
  34.  teForceLeft = -2,
  35.  
  36. /* new names for the Justification styles */
  37.  teFlushDefault = 0,                                    /*flush according to the line direction */
  38.  teCenter = 1,                                            /*center justify */
  39.  teFlushRight = -1,                                        /*flush right for all scripts */
  40.  teFlushLeft = -2,                                        /*flush left for all scripts */
  41.  
  42. /* Set/Replace style modes */
  43.  fontBit = 0,                                            /*set font*/
  44.  faceBit = 1,                                            /*set face*/
  45.  sizeBit = 2,                                            /*set size*/
  46.  clrBit = 3,                                            /*set color*/
  47.  addSizeBit = 4,                                        /*add size mode*/
  48.  toglBit = 5,                                            /*set faces in toggle mode*/
  49.  
  50. /* TESetStyle/TEContinuousStyle modes */
  51.  doFont = 1,                                            /* set font (family) number*/
  52.  doFace = 2,                                            /*set character style*/
  53.  doSize = 4,                                            /*set type size*/
  54.  doColor = 8,                                            /*set color*/
  55.  doAll = 15,                                            /*set all attributes*/
  56.  addSize = 16                                            /*adjust type size*/
  57. };
  58. enum {
  59.  doToggle = 32,                                            /*toggle mode for TESetStyle & TEContinuousStyle*/
  60.  
  61. /* offsets into TEDispatchRec */
  62.  EOLHook = 0,                                            /*[ProcPtr] TEEOLHook*/
  63.  DRAWHook = 4,                                            /*[ProcPtr] TEWidthHook*/
  64.  WIDTHHook = 8,                                            /*[ProcPtr] TEDrawHook*/
  65.  HITTESTHook = 12,                                        /*[ProcPtr] TEHitTestHook*/
  66.  nWIDTHHook = 24,                                        /*[ProcPtr] nTEWidthHook*/
  67.  TextWidthHook = 28,                                    /*[ProcPtr] TETextWidthHook*/
  68.  
  69. /* selectors for TECustomHook */
  70.  intEOLHook = 0,                                        /*TEIntHook value*/
  71.  intDrawHook = 1,                                        /*TEIntHook value*/
  72.  intWidthHook = 2,                                        /*TEIntHook value*/
  73.  intHitTestHook = 3,                                    /*TEIntHook value*/
  74.  intNWidthHook = 6,                                        /*TEIntHook value for new version of WidthHook*/
  75.  intTextWidthHook = 7,                                    /*TEIntHook value for new TextWidthHook*/
  76.  
  77. /* feature or bit definitions for TEFeatureFlag */
  78.  teFAutoScr = 0,                                        /*00000001b*/
  79.  teFTextBuffering = 1,                                    /*00000010b*/
  80.  teFOutlineHilite = 2,                                    /*00000100b*/
  81.  teFInlineInput = 3,                                    /*00001000b*/
  82.  teFUseTextServices = 4,                                /*00010000b*/
  83.  
  84. /* action for the new "bit (un)set" interface, TEFeatureFlag */
  85.  TEBitClear = 0,
  86.  TEBitSet = 1                                            /*set the selector bit*/
  87. };
  88. enum {
  89.  TEBitTest = -1,                                        /*no change; just return the current setting*/
  90.  
  91. /*constants for identifying the routine that called FindWord */
  92.  teWordSelect = 4,                                        /*clickExpand to select word*/
  93.  teWordDrag = 8,                                        /*clickExpand to drag new word*/
  94.  teFromFind = 12,                                        /*FindLine called it ($0C)*/
  95.  teFromRecal = 16                                        /*RecalLines called it ($10)*/
  96. };
  97.  
  98. typedef pascal Boolean (*WordBreakProcPtr)(Ptr text, short charPos);
  99. typedef pascal Boolean (*ClikLoopProcPtr)(void);
  100.  
  101. struct TERec {
  102.  Rect destRect;
  103.  Rect viewRect;
  104.  Rect selRect;
  105.  short lineHeight;
  106.  short fontAscent;
  107.  Point selPoint;
  108.  short selStart;
  109.  short selEnd;
  110.  short active;
  111.  WordBreakProcPtr wordBreak;
  112.  ClikLoopProcPtr clikLoop;
  113.  long clickTime;
  114.  short clickLoc;
  115.  long caretTime;
  116.  short caretState;
  117.  short just;
  118.  short teLength;
  119.  Handle hText;
  120.  short recalBack;
  121.  short recalLines;
  122.  short clikStuff;
  123.  short crOnly;
  124.  short txFont;
  125.  Style txFace;                                            /*txFace is unpacked byte*/
  126.  char filler;
  127.  short txMode;
  128.  short txSize;
  129.  GrafPtr inPort;
  130.  ProcPtr highHook;
  131.  ProcPtr caretHook;
  132.  short nLines;
  133.  short lineStarts[16001];
  134. };
  135.  
  136. typedef struct TERec TERec;
  137. typedef TERec *TEPtr, **TEHandle;
  138.  
  139. typedef char Chars[32001];
  140. typedef char *CharsPtr,**CharsHandle;
  141.  
  142. struct StyleRun {
  143.  short startChar;                                        /*starting character position*/
  144.  short styleIndex;                                        /*index in style table*/
  145. };
  146.  
  147. typedef struct StyleRun StyleRun;
  148.  
  149. struct STElement {
  150.  short stCount;                                            /*number of runs in this style*/
  151.  short stHeight;                                        /*line height*/
  152.  short stAscent;                                        /*font ascent*/
  153.  short stFont;                                            /*font (family) number*/
  154.  Style stFace;                                            /*character Style*/
  155.  char filler;                                            /*stFace is unpacked byte*/
  156.  short stSize;                                            /*size in points*/
  157.  RGBColor stColor;                                        /*absolute (RGB) color*/
  158. };
  159.  
  160. typedef struct STElement STElement;
  161.  
  162. typedef STElement TEStyleTable[1777], *STPtr, **STHandle;
  163.  
  164. struct LHElement {
  165.  short lhHeight;                                        /*maximum height in line*/
  166.  short lhAscent;                                        /*maximum ascent in line*/
  167. };
  168.  
  169. typedef struct LHElement LHElement;
  170.  
  171. typedef LHElement LHTable[8001], *LHPtr, **LHHandle;    /* ARRAY [0..8000] OF LHElement */
  172.  
  173. struct ScrpSTElement {
  174.  long scrpStartChar;                                    /*starting character position*/
  175.  short scrpHeight;                                        /*starting character position*/
  176.  short scrpAscent;
  177.  short scrpFont;
  178.  Style scrpFace;                                        /*unpacked byte*/
  179.  char filler;                                            /*scrpFace is unpacked byte*/
  180.  short scrpSize;
  181.  RGBColor scrpColor;
  182. };
  183.  
  184. typedef struct ScrpSTElement ScrpSTElement;
  185.  
  186. typedef ScrpSTElement ScrpSTTable[1601];                /* ARRAY [0..1600] OF ScrpSTElement */
  187.  
  188. struct StScrpRec {
  189.  short scrpNStyles;                                        /*number of styles in scrap*/
  190.  ScrpSTTable scrpStyleTab;                                /*table of styles for scrap*/
  191. };
  192.  
  193. typedef struct StScrpRec StScrpRec;
  194. typedef StScrpRec *StScrpPtr, **StScrpHandle;
  195.  
  196. struct NullStRec {
  197.  long teReserved;                                        /*reserved for future expansion*/
  198.  StScrpHandle nullScrap;                                /*handle to scrap style table*/
  199. };
  200.  
  201. typedef struct NullStRec NullStRec;
  202. typedef NullStRec *NullStPtr, **NullStHandle;
  203.  
  204. struct TEStyleRec {
  205.  short nRuns;                                            /*number of style runs*/
  206.  short nStyles;                                            /*size of style table*/
  207.  STHandle styleTab;                                        /*handle to style table*/
  208.  LHHandle lhTab;                                        /*handle to line-height table*/
  209.  long teRefCon;                                            /*reserved for application use*/
  210.  NullStHandle nullStyle;                                /*Handle to style set at null selection*/
  211.  StyleRun runs[8001];                                    /*ARRAY [0..8000] OF StyleRun*/
  212. };
  213.  
  214. typedef struct TEStyleRec TEStyleRec;
  215. typedef TEStyleRec *TEStylePtr, **TEStyleHandle;
  216.  
  217. struct TextStyle {
  218.  short tsFont;                                            /*font (family) number*/
  219.  Style tsFace;                                            /*character Style*/
  220.  char filler;                                            /*tsFace is unpacked byte*/
  221.  short tsSize;                                            /*size in point*/
  222.  RGBColor tsColor;                                        /*absolute (RGB) color*/
  223. };
  224.  
  225. typedef struct TextStyle TextStyle;
  226. typedef TextStyle *TextStylePtr, **TextStyleHandle;
  227.  
  228.  
  229. typedef short TEIntHook;
  230.  
  231. #ifdef __cplusplus
  232. extern "C" {
  233. #endif
  234. pascal void TEInit(void)
  235.  = 0xA9CC; 
  236. pascal TEHandle TENew(const Rect *destRect,const Rect *viewRect)
  237.  = 0xA9D2; 
  238. pascal void TEDispose(TEHandle hTE)
  239.  = 0xA9CD; 
  240. pascal void TESetText(const void *text,long length,TEHandle hTE)
  241.  = 0xA9CF; 
  242. pascal CharsHandle TEGetText(TEHandle hTE)
  243.  = 0xA9CB; 
  244. pascal void TEIdle(TEHandle hTE)
  245.  = 0xA9DA; 
  246. pascal void TESetSelect(long selStart,long selEnd,TEHandle hTE)
  247.  = 0xA9D1; 
  248. pascal void TEActivate(TEHandle hTE)
  249.  = 0xA9D8; 
  250. pascal void TEDeactivate(TEHandle hTE)
  251.  = 0xA9D9; 
  252. pascal void TEKey(short key,TEHandle hTE)
  253.  = 0xA9DC; 
  254. pascal void TECut(TEHandle hTE)
  255.  = 0xA9D6; 
  256. pascal void TECopy(TEHandle hTE)
  257.  = 0xA9D5; 
  258. pascal void TEPaste(TEHandle hTE)
  259.  = 0xA9DB; 
  260. pascal void TEDelete(TEHandle hTE)
  261.  = 0xA9D7; 
  262. pascal void TEInsert(const void *text,long length,TEHandle hTE)
  263.  = 0xA9DE; 
  264. pascal void TESetJust(short just,TEHandle hTE)
  265.  = 0xA9DF; 
  266. pascal void TEUpdate(const Rect *rUpdate,TEHandle hTE)
  267.  = 0xA9D3; 
  268. pascal void TextBox(const void *text,long length,const Rect *box,short just)
  269.  = 0xA9CE; 
  270. pascal void TEScroll(short dh,short dv,TEHandle hTE)
  271.  = 0xA9DD; 
  272. pascal void TESelView(TEHandle hTE)
  273.  = 0xA811; 
  274. pascal void TEPinScroll(short dh,short dv,TEHandle hTE)
  275.  = 0xA812; 
  276. pascal void TEAutoView(Boolean fAuto,TEHandle hTE)
  277.  = 0xA813; 
  278. #define TEScrapHandle() (* (Handle*) 0xAB4)
  279. pascal void TECalText(TEHandle hTE)
  280.  = 0xA9D0; 
  281. pascal short TEGetOffset(Point pt,TEHandle hTE)
  282.  = 0xA83C; 
  283. pascal Point TEGetPoint(short offset,TEHandle hTE)
  284.  = {0x3F3C,0x0008,0xA83D}; 
  285. pascal void TEClick(Point pt,Boolean fExtend,TEHandle h)
  286.  = 0xA9D4; 
  287. pascal TEHandle TEStylNew(const Rect *destRect,const Rect *viewRect)
  288.  = 0xA83E; 
  289. pascal TEHandle TEStyleNew(const Rect *destRect,const Rect *viewRect)
  290.  = 0xA83E; 
  291. pascal void SetStylHandle(TEStyleHandle theHandle,TEHandle hTE)
  292.  = {0x3F3C,0x0005,0xA83D}; 
  293. pascal void SetStyleHandle(TEStyleHandle theHandle,TEHandle hTE)
  294.  = {0x3F3C,0x0005,0xA83D}; 
  295. pascal TEStyleHandle GetStylHandle(TEHandle hTE)
  296.  = {0x3F3C,0x0004,0xA83D}; 
  297. pascal TEStyleHandle GetStyleHandle(TEHandle hTE)
  298.  = {0x3F3C,0x0004,0xA83D}; 
  299. pascal void TEGetStyle(short offset,TextStyle *theStyle,short *lineHeight,
  300.  short *fontAscent,TEHandle hTE)
  301.  = {0x3F3C,0x0003,0xA83D}; 
  302. pascal void TEStylPaste(TEHandle hTE)
  303.  = {0x3F3C,0x0000,0xA83D}; 
  304. pascal void TEStylePaste(TEHandle hTE)
  305.  = {0x3F3C,0x0000,0xA83D}; 
  306. pascal void TESetStyle(short mode,const TextStyle *newStyle,Boolean redraw,
  307.  TEHandle hTE)
  308.  = {0x3F3C,0x0001,0xA83D}; 
  309. pascal void TEReplaceStyle(short mode,const TextStyle *oldStyle,const TextStyle *newStyle,
  310.  Boolean redraw,TEHandle hTE)
  311.  = {0x3F3C,0x0002,0xA83D}; 
  312. pascal StScrpHandle GetStylScrap(TEHandle hTE)
  313.  = {0x3F3C,0x0006,0xA83D}; 
  314. pascal StScrpHandle GetStyleScrap(TEHandle hTE)
  315.  = {0x3F3C,0x0006,0xA83D}; 
  316. pascal void TEStylInsert(const void *text,long length,StScrpHandle hST,
  317.  TEHandle hTE)
  318.  = {0x3F3C,0x0007,0xA83D}; 
  319. pascal void TEStyleInsert(const void *text,long length,StScrpHandle hST,
  320.  TEHandle hTE)
  321.  = {0x3F3C,0x0007,0xA83D}; 
  322. pascal long TEGetHeight(long endLine,long startLine,TEHandle hTE)
  323.  = {0x3F3C,0x0009,0xA83D}; 
  324. pascal Boolean TEContinuousStyle(short *mode,TextStyle *aStyle,TEHandle hTE)
  325.  = {0x3F3C,0x000A,0xA83D}; 
  326. pascal void SetStylScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  327.  Boolean redraw,TEHandle hTE)
  328.  = {0x3F3C,0x000B,0xA83D}; 
  329. pascal void SetStyleScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  330.  Boolean redraw,TEHandle hTE)
  331.  = {0x3F3C,0x000B,0xA83D}; 
  332. pascal void TECustomHook(TEIntHook which,ProcPtr *addr,TEHandle hTE)
  333.  = {0x3F3C,0x000C,0xA83D}; 
  334. pascal long TENumStyles(long rangeStart,long rangeEnd,TEHandle hTE)
  335.  = {0x3F3C,0x000D,0xA83D}; 
  336. pascal short TEFeatureFlag(short feature,short action,TEHandle hTE)
  337.  = {0x3F3C,0x000E,0xA83D}; 
  338. #define TEGetScrapLen() ((long) * (unsigned short *) 0x0AB0)
  339. pascal void TESetScrapLen(long length); 
  340. pascal OSErr TEFromScrap(void); 
  341. pascal OSErr TEToScrap(void); 
  342. pascal void SetClikLoop(ClikLoopProcPtr clikProc,TEHandle hTE); 
  343. pascal void SetWordBreak(WordBreakProcPtr wBrkProc,TEHandle hTE); 
  344. void teclick(Point *pt,Boolean fExtend,TEHandle h); 
  345. #ifdef __cplusplus
  346. }
  347. #endif
  348.  
  349. #endif
  350.